package top.yunp.sstws;

import com.formdev.flatlaf.FlatDarkLaf;
import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.FlatLightLaf;
import com.jthemedetecor.OsThemeDetector;

public class Main {

    private static OsThemeDetector themeDetector;

    public static void main(String[] args) {
        configTheme();

        new FirstView();
    }

    private static void syncTheme() {
        if (themeDetector.isDark()) {
            FlatDarkLaf.setup();
        } else {
            FlatLightLaf.setup();
        }
        FlatLaf.updateUI();
    }

    private static void configTheme() {
        System.setProperty("apple.awt.application.appearance", "system");
        themeDetector = OsThemeDetector.getDetector();
        themeDetector.registerListener(isDark -> {
            syncTheme();
        });
        syncTheme();
    }
}